package com.sun.dailyprj.provider;

import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.sun.dailyprj.R;
import com.sun.dailyprj.databinding.ActivityProviderBinding;


public class ContentProviderActivity extends AppCompatActivity{
    private ActivityProviderBinding mBinding;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_provider);
        mBinding.setProvider(this);

        startLogService();

    }

    public void calltest() {
        ContentResolver contentResolver = this.getContentResolver();
        Uri uri = Uri.parse("content://com.sun.provider");
        Bundle data = new Bundle();
        data.putString("msg","calltest");
        Bundle bundle = contentResolver.call(uri, "event", "record", data);
        String returnCall = bundle.getString("msg");
        Log.i("main", "-------------->" + returnCall);
    }

    private void startLogService(){
        Intent intent = new Intent(this,LogService.class);
        LogService.startService(this,intent);
    }

    public void onTestClick(View view){
        calltest();
    }
}
